
import request from '@/utils/request'

const api = {
    getSettlementList: '/v1/settlement/page/list', // 获取结算单分页列表
    uploadSettlementExcel: '/v1/settlement/apply', // 申请结算单excel上传
    configmSettlementExcel: '/v1/settlement/generate', // 生成结算单
    contineuSettlementExcel: '/v1/settlement/apply/continue', // 结算单继续上传
    passSettlementOrder: '/v1/settlement/pass/', // 通过结算审核
    refuseSettlementOrder: '/v1/settlement/refuse', // 驳回结算单审核
    authSettlementOrder: '/v1/settlement/auth/', // 结算单授权
    cancelSettlementOrder: '/v1/settlement/cancel/', // 结算单取消
    deleteSettlementOrder: '/v1/settlement/delete/', // 结算单删除
    getSettlementDetail: '/v1/settlement/detail/', // 获取结算单详情
    settlementDetailList: '/v1/settlement/detail/list', // 结算明细
    settlementPay: '/v1/settlement/pay', // 结算单确认支付
    downloadSettlementDetailList: '/v1/settlement/detail/list/export', // 导出结算名单
}

// 获取结算分页列表
export function getSettlementList (parameter) {
    return request({
        url: api.getSettlementList,
        method: 'get',
        headers: {
            'name':'getSettlementList',
        },
        params: parameter
    })
}

// 申请结算单excel上传
export function uploadSettlementExcel (parameter) {
    return request({
        url: api.uploadSettlementExcel,
        method: 'post',
        headers: {
            'name':'uploadSettlementExcel',
            'file': true,
            'Content-Type': 'multipart/form-data'
        },
        data: parameter
    })
}

// 生成结算单
export function configmSettlementExcel (parameter) {
    return request({
        url: api.configmSettlementExcel,
        method: 'post',
        headers: {
            'name':'configmSettlementExcel',
        },
        data: parameter
    })
}

// 结算单继续上传
export function contineuSettlementExcel (parameter) {
    return request({
        url: api.contineuSettlementExcel,
        method: 'post',
        headers: {
            'name':'contineuSettlementExcel',
        },
        data: parameter
    })
}

// 通过结算审核
export function passSettlementOrder (settlementId) {
    return request({
        url: api.passSettlementOrder + settlementId,
        method: 'post',
        headers: {
            'name':'passSettlementOrder',
        },
        data: {}
    })
}

// 驳回结算单
export function refuseSettlementOrder (parameter) {
    return request({
        url: api.refuseSettlementOrder,
        method: 'post',
        headers: {
            'name':'refuseSettlementOrder',
        },
        data: parameter
    })
}

// 结算单授权
export function authSettlementOrder (settlementId) {
    return request({
        url: api.authSettlementOrder + settlementId,
        method: 'post',
        headers: {
            'name':'authSettlementOrder',
        },
        data: {}
    })
}

// 结算单取消
export function cancelSettlementOrder (settlementId) {
    return request({
        url: api.cancelSettlementOrder + settlementId,
        method: 'post',
        headers: {
            'name':'cancelSettlementOrder',
        },
        data: {}
    })
}

// 结算单删除
export function deleteSettlementOrder (settlementId) {
    return request({
        url: api.deleteSettlementOrder + settlementId,
        method: 'post',
        headers: {
            'name':'deleteSettlementOrder',
        },
        data: {}
    })
}

// 获取结算单详情
export function getSettlementDetail (settlementId) {
    return request({
        url: api.getSettlementDetail + settlementId,
        method: 'get',
        headers: {
            'name':'getSettlementDetail',
        },
        params: {}
    })
}

// 结算明细
export function settlementDetailList (parameter) {
    return request({
        url: api.settlementDetailList,
        method: 'get',
        headers: {
            'name':'settlementDetailList',
        },
        params: parameter
    })
}

// 结算单确认支付 
export function settlementPay (parameter) {
    return request({
        url: api.settlementPay,
        method: 'post',
        headers: {
            'name':'settlementPay',
        },
        data: parameter
    })
}

// 导出结算名单
export function downloadSettlementDetailList (parameter) {
    return request({
        url: api.downloadSettlementDetailList,
        method: 'get',
        responseType: "arraybuffer",
        headers: {
            'name':'downloadSettlementDetailList',
        },
        params: parameter
    })
}